package cn.edu.tju.elm.model;

/**
 * 信用评级枚举
 * 只有VIP用户才有透支额度，额度为固定金额
 */
public enum CreditRating {
    VIP("VIP用户", 2000.00, 30, 0.08),     // VIP用户：固定额度5000元，免息期30天，年利率8%
    REGULAR("普通用户", 0.00, 0, 0.0),     // 普通用户：无透支额度
    DEFAULT("违约用户", 0.00, 0, 0.24);    // 违约用户：无透支额度，高罚息利率

    private final String description;
    private final double fixedCreditLimit; // 固定信用额度
    private final int interestFreeDays;    // 免息天数
    private final double annualInterestRate; // 年利率

    CreditRating(String description, double fixedCreditLimit, int interestFreeDays, double annualInterestRate) {
        this.description = description;
        this.fixedCreditLimit = fixedCreditLimit;
        this.interestFreeDays = interestFreeDays;
        this.annualInterestRate = annualInterestRate;
    }

    public String getDescription() {
        return description;
    }

    public double getFixedCreditLimit() {
        return fixedCreditLimit;
    }

    public int getInterestFreeDays() {
        return interestFreeDays;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    /**
     * 检查是否为VIP用户
     */
    public boolean isVip() {
        return this == VIP;
    }

    /**
     * 获取最大允许逾期天数（不降低信用评级）
     */
    public int getMaxAllowedOverdueDays() {
        switch (this) {
            case VIP: return 15;      // VIP用户允许15天
            case REGULAR: return 0;   // 普通用户不允许逾期
            default: return 0;        // 违约用户不允许逾期
        }
    }

    /**
     * 获取每日利率
     */
    public double getDailyInterestRate() {
        return annualInterestRate / 365;
    }
}